package com.sgb.kjwl.view.ui.fragment.home;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.core.util.Pair;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout;
import com.google.gson.Gson;
import com.sgb.alimaplibrary.SelectAddressActivity;
import com.sgb.auction.activity.AuctionHallActivity;
import com.sgb.jicai.view.activity.FactoryCentralizedActivity;
import com.sgb.jicai.view.activity.JcMyPriceActivity;
import com.sgb.jicai.view.activity.JiCaiDaTingActivity;
import com.sgb.jicai.view.activity.MyCenterMyJoinActivity;
import com.sgb.jicai.view.activity.XuFangFaQiActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FragmentGoodsMainGoodsList3Binding;
import com.sgb.kjwl.di.material.DaggerMaterialFragComponent;
import com.sgb.kjwl.di.material.MaterialFragModule;
import com.sgb.kjwl.model.entity.GoodsListTypeEntity;
import com.sgb.kjwl.model.entity.HomeMenuEntity;
import com.sgb.kjwl.model.entity.IndustryHomeListEntity;
import com.sgb.kjwl.model.entity.UpdateEntity;
import com.sgb.kjwl.model.entity.home.UpdateIndexEvent;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.utils.NumberConstant;
import com.sgb.kjwl.view.event.CategoryEvent2;
import com.sgb.kjwl.view.event.LoginEvent;
import com.sgb.kjwl.view.ui.activity.enterprise.MakeOverActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.NeedActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.ProfessionalQuoteActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.ProfessionalTeamChangeActivity;
import com.sgb.kjwl.view.ui.activity.lease.LeaseHallActivity2;
import com.sgb.kjwl.view.ui.activity.manage.CompanyTradesActivity;
import com.sgb.kjwl.view.ui.activity.manage.EpAssestActivity;
import com.sgb.kjwl.view.ui.activity.manage.IPActivity;
import com.sgb.kjwl.view.ui.activity.manage.ManageActivity;
import com.sgb.kjwl.view.ui.activity.manage.SpecialQualificationActivity;
import com.sgb.kjwl.view.ui.activity.manage.TradeHonorActivity;
import com.sgb.kjwl.view.ui.activity.material.hall.NewDemandHallActivity;
import com.sgb.kjwl.view.ui.activity.packers.FindPackersActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersEmploymentActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersEngineeringCompanyActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersFindPeopleActivity;
import com.sgb.kjwl.view.ui.activity.packers.ServicesCompanyActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickBiddingListActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickHallActivity3;
import com.sgb.kjwl.view.ui.activity.pick.PickListActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickNoticeActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickWinningNoticeActivity;
import com.sgb.kjwl.view.ui.activity.quotedprice.QuotedPriceActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.activity.supplier3.SupplierActivity4;
import com.sgb.kjwl.view.ui.activity.transport.BiddingTransportHallActivity;
import com.sgb.kjwl.view.ui.activity.transport.DriverLookForGoodsActivity;
import com.sgb.kjwl.view.ui.activity.transport.GoodsCarsActivity;
import com.sgb.kjwl.view.ui.adapter.home.GoodsNavigationAdapter;
import com.sgb.kjwl.view.ui.quickentry.QuickEntryClickListener;
import com.sgb.kjwl.view.ui.quickentry.QuickEntryEntity;
import com.sgb.kjwl.view.ui.quickentry.QuickEntryPopWindow;
import com.sgb.link.router.PathMerchant;
import com.sgb.link.router.PathTeam;
import com.sgb.member.ui.activity.MemberAuditActivity;
import com.sgb.member.ui.activity.MemberInviteOrApplyActivity;
import com.sgb.member.ui.activity.MemberManageActivity;
import com.sgb.zhaocai.view.demand.activity.DemandForecastActivity;
import com.swgk.core.base.AppFragment;
import com.swgk.core.mmkvutil.CacheMarker;
import com.swgk.core.mmkvutil.DatalUtils;
import com.swgk.core.mmkvutil.MkvUtils;
import com.swgk.core.util.UserOperating;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.util.StringUtil;
import com.swgk.core.view.entity.MenuEntity;
import com.sgb.kjwl.model.entity.ProvinceEntity;
import com.sgb.kjwl.model.entity.request.MaterialFilterJson;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.sgb.kjwl.model.entity.user.AddressEntity;
import com.sgb.kjwl.model.entity.user.AreaChooseEntity;
import com.sgb.kjwl.model.entity.user.ConcreteEntity;
import com.sgb.kjwl.model.entity.user.GoodsListEntity;
import com.sgb.kjwl.model.entity.user.MaterChooseEntity;
import com.sgb.kjwl.model.entity.user.RecommendListEntity;
import com.sgb.kjwl.utils.ActivityClassHelper;
import com.sgb.kjwl.utils.LocationUtil;
import com.sgb.kjwl.view.event.ChooseAreaEvent;
import com.swgk.core.event.EventConstant;
import com.sgb.link.event.LeaseEvent;
import com.sgb.link.event.MaterialEvent;
import com.sgb.kjwl.view.ui.activity.home.HomeCategoryActivity;
import com.sgb.kjwl.view.ui.activity.material.ConcreteDetailActivity2;
import com.sgb.kjwl.view.ui.activity.material.GoodsAggregateActivity;
import com.sgb.kjwl.view.ui.activity.self.shop.ShopGoodsDetailActivity;
import com.sgb.kjwl.view.ui.adapter.search.MaterialAdapter;
import com.sgb.kjwl.view.ui.adapter.search.MatterChooseAdapter;
import com.sgb.kjwl.view.ui.adapter.search.RecommendGoodsAdapter;
import com.sgb.kjwl.view.ui.adapter.search.RecommendMatterChooseAdapter;
import com.sgb.kjwl.view.widget.DictWindow5;
import com.sgb.kjwl.view.widget.GoodsThreeLevelCategorizeView;
import com.sgb.kjwl.view.widget.MatterChooseMaterialFliterPopWindow3;
import com.sgb.kjwl.view.widget.ThreeLevelAreaWindow;
import com.sgb.kjwl.view.widget.transport.MatterChooseWindow;
import com.sgb.kjwl.viewmodel.home.GoodsMainGoodsListModel3;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.base.model.entity.RequestCode;
import com.swgk.core.base.model.entity.SelectPopEntity;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.recyclerview.entity.BaseAreaEntity;
import com.swgk.core.util.ResolutionUtil;
import com.swgk.core.xrecyclerview.AppBarStateChangeListener;
import com.swgk.core.xrecyclerview.XRecyclerView;
import com.zhy.view.flowlayout.TagAdapter;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import javax.inject.Inject;

import static com.sgb.kjwl.utils.NumberConstant.TEAM_CONSTRUCTION;

/**
 * 首页模块商品界面的商品展示界面(包含商品、自营和促销)
 * 说明：拷贝的源文件GoodsMainGoodsListFragment1，主要优化的部分是三级分类筛选逻辑和侧滑筛选联动的逻辑
 *
 * @author qiangheNooooo
 */
public class GoodsMainGoodsListFragment3 extends AppFragment implements QuickEntryClickListener {

    @Inject
    GoodsMainGoodsListModel3 mModel;
    private FragmentGoodsMainGoodsList3Binding mBinding;
    private String mLon = "0";
    private String mLat = "0";
    private MatterChooseMaterialFliterPopWindow3 mPopWindow;
    private DictWindow5 distanceWindow5;
    private DictWindow5 brandWindow5;
    private List<MenuEntity<MenuEntity<MenuEntity>>> mGoodsType;
    private int mPageNum = 1;
    private String distanceId = "";
    private String aBrandId = "";
    private String mPriceSort = "0";
    private String mCid1 = "";
    private String mCid3 = "";
    private String mCategoryId = "";
    private String brandName = "-100";
    private List<String> mBrandId = new ArrayList<>();
    private final List<String> brandId = new ArrayList<>();
    private List<String> mMaterValue = new ArrayList<>();
    private boolean isLoadMoreGoodsList;
    private boolean isLoadMoreRecommendGoodsList;
    private MaterialAdapter mMaterialAdapter;
    private List<String> mAreaId = new ArrayList<>();
    private String mCityId = "";
    private String mProvince = "";
    private int mRecommendPageNum = 0;
    private String mRecommendValId = "";
    private String mItemCid1 = "";
    private String mItemCid2 = "";
    private String mItemCid3 = "";
    private RecommendGoodsAdapter mRecommendGoodsAdapter;
    private ThreeLevelAreaWindow mThreeLevelPopWindow;
    private MatterChooseAdapter mMatterChooseAdapter;
    private RecommendMatterChooseAdapter mRecommendMatterChooseAdapter;
    /**
     * 筛选类别数据
     */
    private final List<DictEntity3> matterChooseMaterialclassone = new ArrayList<>();
    private final List<DictEntity3> matterChooseMaterialType = new ArrayList<>();
    private final List<DictEntity3> matterChooseMaterialName = new ArrayList<>();
    private final List<DictEntity3> matterChooseMaterialArea = new ArrayList<>();
    private final List<DictEntity3> matterChooseMaterialDistance = new ArrayList<>();
    /**
     * 商品类别
     */
    private MenuEntity<MenuEntity<MenuEntity>> firstMenuEntity = new MenuEntity<>();
    private String mArea = "";
    private String mDistanceName = "";
    private String mBrandName = "";
    private Map<String, MaterChooseEntity.TypeBean> mRecommendStr = new HashMap<>();
    private Map<String, MaterChooseEntity.TypeBean> mStr = new HashMap<>();
    private List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> mAreaList = new ArrayList<>();
    private MaterialHomeFragment1 materialHomeFragment;
    private StringBuilder sbl;

    private AppBarLayout.LayoutParams layoutParams;
    private boolean isAppBarExpended = false;
    private static final String TGA = "GoodsMainGoodsListFragment3";
    private boolean isParentAppBarCollapsed = false;
    private boolean isCheckST = false;
    private boolean isUpDragging = true;
    private final static int FLAG_NO_SCROLL = AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL;
    /**
     * 0是推荐商品 1是全部商品
     */
    private int type;
    /**
     * 推荐商品
     * true 自营商品 false 非自营
     */
    private boolean isSelfEmployedGoods;
    /**
     * 推荐商品
     * true 促销商品 false 非促销商品
     */
    private boolean isPromotionalGoods;
    /**
     * 推荐商品
     * true 促销商品 false 非促销商品
     */
    private boolean isPromotionalChecked;
    /**
     * 是否是自营产品
     */
    private boolean isZiYingChecked = false;
    /**
     * 是否与地区关联
     */
    private boolean isRegionalConnection;
    /**
     * 推荐商品
     * 是否是热销产品
     */
    private boolean isSellGoodGoodsChecked;
    /**
     * 推荐商品
     * 是否是会员价商品
     */
    private boolean isHuiYuanChecked;
    /**
     *
     */
    private int industryPosition;
    /**
     * 是否重置定位
     */
    private boolean isRePositioning;
    /**
     * 第一级商品分类选中下标
     */
    private int indexCid1 = 0;
    /**
     * 第二级商品分类选中下标
     */
    private int indexCid2 = 0;
    /**
     * 距离
     */
    private SelectPopEntity selectPopEntity3;
    /**
     * 品牌
     */
    private SelectPopEntity brandPopEntity;

    /**
     * 会员
     */
    private SelectPopEntity selectHuiYuan;
    /**
     * 第三级商品分类选中下标
     */
    private int indexCid3 = 0;

    private List<SelectPopEntity> moveStrings = new ArrayList<>();
    private int testPosition;
    private List<MaterChooseEntity> data;
    String[] name = null;
    private String mProvinceName = "";

    private boolean isNeedFilterValue = false;
    private String hyid = "";
    private String firstCategoryId = "";
    private String secondCategoryId = "";
    private String thirdCategoryId = "";


    private int choice_Industry = 0;

    private QuickEntryPopWindow quickEntryPopWindow; //快捷入口弹框
    private List<MenuEntity> titleData = new ArrayList<>();
    private List<MenuEntity<MenuEntity<MenuEntity>>> mMaterialData = new ArrayList<>();

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerMaterialFragComponent.builder()
                .appComponent(appComponent)
                .materialFragModule(new MaterialFragModule(this))
                .build()
                .inject(this);
    }

    /**
     * @param type                     0表示商品首页推荐商品模块，1表示全部商品模块
     * @param goodsType                三级商品分类数据集合
     * @param firstCategoryId          第一级选中商品分类id
     * @param secondCategoryId         第二级选中商品分类id
     * @param thirdCategoryId          第三级选中商品分类id
     * @param isSelfEmployedGoodsGoods 是否是自营商品模块
     * @param promotionalGoods         是否是促销商品模块
     * @param isRegionalConnection     是否与地区相关联
     * @return
     */
    public static GoodsMainGoodsListFragment3 newInstance(int type, List<MenuEntity<MenuEntity<MenuEntity>>> goodsType, @NonNull String firstCategoryId,
                                                          @Nullable String secondCategoryId, @Nullable String thirdCategoryId, boolean isSelfEmployedGoodsGoods, boolean promotionalGoods, boolean isRegionalConnection) {
        GoodsMainGoodsListFragment3 goodsMainGoodsListFragment = new GoodsMainGoodsListFragment3();
        Bundle bundle = new Bundle();
        bundle.putInt("goodsListType", type);
        bundle.putSerializable("goodsList", (Serializable) goodsType);
        bundle.putString("firstCategoryId", firstCategoryId);
        bundle.putString("secondCategoryId", secondCategoryId);
        bundle.putString("thirdCategoryId", thirdCategoryId);
        bundle.putBoolean("isSelfEmployedGoods", isSelfEmployedGoodsGoods);
        bundle.putBoolean("promotionalGoods", promotionalGoods);
        bundle.putBoolean("isRegionalConnection", isRegionalConnection);
        goodsMainGoodsListFragment.setArguments(bundle);
        return goodsMainGoodsListFragment;
    }

    public static GoodsMainGoodsListFragment3 newInstance(int type, List<MenuEntity<MenuEntity<MenuEntity>>> goodsType, @NonNull String firstCategoryId,
                                                          @Nullable String secondCategoryId, @Nullable String thirdCategoryId, boolean isSelfEmployedGoodsGoods, boolean promotionalGoods, boolean isRegionalConnection, String hyid) {
        GoodsMainGoodsListFragment3 goodsMainGoodsListFragment = new GoodsMainGoodsListFragment3();
        Bundle bundle = new Bundle();
        bundle.putInt("goodsListType", type);
        bundle.putSerializable("goodsList", (Serializable) goodsType);
        bundle.putString("firstCategoryId", firstCategoryId);
        bundle.putString("secondCategoryId", secondCategoryId);
        bundle.putString("thirdCategoryId", thirdCategoryId);
        bundle.putBoolean("isSelfEmployedGoods", isSelfEmployedGoodsGoods);
        bundle.putBoolean("promotionalGoods", promotionalGoods);
        bundle.putBoolean("isRegionalConnection", isRegionalConnection);
        bundle.putString("hyid", hyid);
        goodsMainGoodsListFragment.setArguments(bundle);
        return goodsMainGoodsListFragment;
    }


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_goods_main_goods_list3, container, false);
        return mBinding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }

    private void initView() {
        assert getArguments() != null;
        type = getArguments().getInt("goodsListType");
        mGoodsType = (List<MenuEntity<MenuEntity<MenuEntity>>>) getArguments().getSerializable("goodsList");
        firstCategoryId = getArguments().getString("firstCategoryId");
        secondCategoryId = getArguments().getString("secondCategoryId");
        thirdCategoryId = getArguments().getString("thirdCategoryId");
        isSelfEmployedGoods = getArguments().getBoolean("isSelfEmployedGoods", false);
        isPromotionalGoods = getArguments().getBoolean("promotionalGoods", false);
        isRegionalConnection = getArguments().getBoolean("isRegionalConnection", false);
        hyid = getArguments().getString("hyid");

        setTextButton();
        mBinding.ivQuickEntry.setVisibility(type == 1 ? View.VISIBLE : View.GONE);
        mBinding.ivQuickEntry.setOnClickListener(this);
        mBinding.sct.onSetCallPop((position, content, bg, entity) -> {
            testPosition = position;
            if ("1".equals(entity.getType())) {
                isZiYingChecked = !isZiYingChecked;
                if (type == 0) {
                    loadRecommendList(false);
                } else {
                    loadAllList(false);
                }
            } else if ("2".equals(entity.getType())) {
                isPromotionalChecked = !isPromotionalChecked;
                if (type == 0) {
                    loadRecommendList(false);
                } else {
                    loadAllList(false);
                }
            } else if ("3".equals(entity.getType())) {
                isSellGoodGoodsChecked = !isSellGoodGoodsChecked;
                if (type == 0) {
                    loadRecommendList(false);
                } else {
                    loadAllList(false);
                }
            } else if ("7".equals(entity.getType())) {
                isHuiYuanChecked = !isHuiYuanChecked;
                if (type == 0) {
                    loadRecommendList(false);
                } else {
                    loadAllList(false);
                }
            } else if ("4".equals(entity.getType())) {
                mBinding.sct.contentSelect(false, true, position);
                EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
                new Handler().postDelayed(() -> mThreeLevelPopWindow.showPopwindow(mBinding.llFragmentGoodsMainGoodsListSelect, 0, 0), 300);
            } else if ("5".equals(entity.getType())) {
                mBinding.sct.contentSelect(false, true, position);
                if (type == 0) {
                    mModel.getFilterDistance(mItemCid1, true);
                    mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg_2);
                } else {
                    mModel.getFilterDistance(mCid1, true);
                }
            } else if ("6".equals(entity.getType())) {
                mBinding.sct.contentSelect(false, true, position);
                if (type == 0) {
                    mModel.getFilterBrandModel(mItemCid3, true);
                    mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg_2);
                } else {
                    mModel.getFilterBrandModel(mCid3, true);
                }
            } else {
                int leftPositon = 0;
//                if (!isSelfEmployedGoods && !isPromotionalGoods) {
//                    leftPositon = 3;
//                } else if (isSelfEmployedGoods) {
//                    leftPositon = 2;
//                } else if (isPromotionalGoods) {
//                    leftPositon = 1;
//                }

                mBinding.sct.contentSelect(false, true, position);
                List<String> mList = new ArrayList<>();

                boolean isChange = false;
                MatterChooseWindow mNameWindow5 = new MatterChooseWindow(getContext());

                mNameWindow5.setVisible(false);
                int finalLeftPositon = leftPositon;
                mNameWindow5.setOnCloseBack(() -> {
                    if (name[position - finalLeftPositon] == null || "".equals(name[position - finalLeftPositon]) || "全部".equals(name[position - finalLeftPositon]) || "不限".equals(name[position - finalLeftPositon])) {
                        mBinding.sct.contentSelect(false, false, position);
                    } else {
                        mBinding.sct.contentSelect(true, false, position);
                    }
                });

                mNameWindow5.setOnCallBack(dictEntity -> {
                    mStr.put(data.get(position - finalLeftPositon).getName(), dictEntity);
                    for (MaterChooseEntity.TypeBean value : mStr.values()) {
                        if (!value.getCid().equals("")) {
                            mList.add(value.getCname());
                        }
                    }

                    name[position - finalLeftPositon] = dictEntity.getCname();
                    mMaterValue = mList;
                    loadAllList(false);
                });

                mNameWindow5.setData(data.get(position - finalLeftPositon).getType());
                mNameWindow5.setBgView(mBinding.grayLayout);
                for (String s : mStr.keySet()) {
                    if (data.get(position - finalLeftPositon).getName().equals(s)) {
                        mNameWindow5.setCheckDefaultById(mStr.get(s).getCid());
                        isChange = true;
                        break;
                    } else {
                        isChange = false;
                    }
                }

                if (!isChange) {
                    mNameWindow5.setCheckDefaultById(data.get(position - finalLeftPositon).getType().get(0).getCid());
                }
                EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
                new Handler().postDelayed(() -> mNameWindow5.showPopwindow(mBinding.llFragmentGoodsMainGoodsListSelect, 0, 0), 300);
            }
        });


        if (isSelfEmployedGoods) {
            mBinding.llSelfEmployed.setVisibility(View.GONE);
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mBinding.llPromotionalGoods.getLayoutParams();
            layoutParams.setMargins(0, 0, ResolutionUtil.dp2px(Objects.requireNonNull(Objects.requireNonNull(requireContext())), 5), 0);
            mBinding.llPromotionalGoods.setLayoutParams(layoutParams);
        } else {
            mBinding.llSelfEmployed.setVisibility(View.VISIBLE);
            mBinding.llSelfEmployed.setOnClickListener(this::onMultiClick);
        }

        if (isPromotionalGoods) {
            mBinding.llPromotionalGoods.setVisibility(View.GONE);
            mBinding.llSellGoods.setVisibility(View.GONE);
        } else {
            mBinding.llPromotionalGoods.setVisibility(View.VISIBLE);
            mBinding.llPromotionalGoods.setOnClickListener(this::onMultiClick);
            mBinding.llSellGoods.setVisibility(View.VISIBLE);
            mBinding.llSellGoods.setOnClickListener(this::onMultiClick);
        }

        if (isRegionalConnection) {
            mProvince = mModel.getAreaCode();
        }
        mBinding.setGoodsFragment(this);
        GoodsListTypeEntity typeEntity = ActivityClassHelper.getGoodsListStyle(getContext(), type);
        mBinding.setGoodsType(typeEntity);
        AppBarLayout.LayoutParams lp = (AppBarLayout.LayoutParams) mBinding.rlGoodsMainGoodsListTab.getLayoutParams();
        lp.setMargins(0, 0, 0, 0);
        mBinding.rlGoodsMainGoodsListTab.setLayoutParams(lp);
        mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.color.white);
        mBinding.setGoodsModel(mModel);
        this.layoutParams = (AppBarLayout.LayoutParams) mBinding.rlGoodsMainGoodsListTab.getLayoutParams();
        this.layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
        mBinding.rlGoodsMainGoodsListTab.setLayoutParams(layoutParams);
        mBinding.categorizeView.addOnTabSelectedListener(new GoodsThreeLevelCategorizeView.TabItemSelectedResultListener() {
            @Override
            public void onFirstCategorizeCallBack
                    (@Nullable @org.jetbrains.annotations.Nullable MenuEntity<MenuEntity<MenuEntity>> firstLevel,
                     int position) {
                if (firstLevel == null) {
                    return;
                }
                firstMenuEntity = firstLevel;
                indexCid1 = position;
                indexCid2 = 0;
                indexCid3 = 0;
                removeBrandTextButton();
                if (type == 0) {
                    mItemCid1 = "";
                    mItemCid2 = "";
                    mItemCid3 = "";
                    mRecommendValId = "";
                    mRecommendStr.clear();
                } else {
                    mCid1 = "";
                    mCategoryId = "";
                    mCid3 = "";
                    if (!isNeedFilterValue) {
                        mPopWindow.setBrandData(new ArrayList<>());
                        mPopWindow.setSpecData(new ArrayList<>());
                        mMaterValue.clear();
                        mStr.clear();
                        brandName = "-100";
                    }
                }
                if ("".equals(firstLevel.getId())) {
                    distanceId = "";
                    mDistanceName = "";
                    setDistanceData(new ArrayList<>(), false);
                    mBinding.tvFragmentGoodsMainGoodsListSelect2.setVisibility(View.GONE);
                    mBinding.sct.removeTextButton(selectPopEntity3);
                } else {
                    mBinding.sct.removeTextButton(selectPopEntity3);
                    mBinding.sct.addTextButton(selectPopEntity3);
                }

                if ("7".equals(firstLevel.getId())) {
                    if (selectHuiYuan != null) {
                        isCheckST = true;
                        mBinding.sct.removeTextButton(selectHuiYuan);
                    }
                } else {
                    if (isCheckST) {
                        isCheckST = false;
                        mBinding.sct.removeAllTextButton();
                        setTextButton();
                    }
                }
                setMatterChooseMaterialType(firstLevel);
                setMatterChooseMaterialName(null);
                if (type == 0) {
                    if ("".equals(firstLevel.getId())) {
                        StringBuilder sbl = new StringBuilder();
                        for (MenuEntity<MenuEntity<MenuEntity>> menuEntity : mGoodsType) {
                            if (!"全部".equals(menuEntity.getName())) {
                                sbl.append(",").append(menuEntity.getId());
                            }
                        }
                        sbl.replace(0, 1, "");
                        if (industryPosition == 0) {
                            mItemCid1 = "";
                        } else {
                            mItemCid1 = sbl.toString();
                        }
                    } else {
                        mItemCid1 = firstLevel.getId();
                    }
                    if (mGoodsType != null && mGoodsType.size() > 1) {
                        loadRecommendList(false);
                    } else {
                        if (mRecommendGoodsAdapter != null) {
                            mRecommendGoodsAdapter.setDatas(null);
                        }
                        mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.GONE);
                        mBinding.flContainer.setVisibility(View.VISIBLE);
                        mBinding.emptyView.setVisibility(View.VISIBLE);
                    }
                } else {
                    mCid1 = firstLevel.getId();
                    loadAllList(false);
                }
                mBinding.rlGoodMatterChoose.setVisibility(View.GONE);
                mBinding.rvGoodMatterChoose.setVisibility(View.GONE);
                mBinding.sct.removeTextButtonList(moveStrings);
                moveStrings.clear();

            }

            @Override
            public void onSecondCategorizeCallBack
                    (@Nullable @org.jetbrains.annotations.Nullable MenuEntity<MenuEntity> secondLevel,
                     int position) {
                if (secondLevel == null) {
                    return;
                }
                indexCid2 = position;
                indexCid3 = 0;
                removeBrandTextButton();
                if (type == 0) {
                    mItemCid2 = "";
                    mItemCid3 = "";
                    mRecommendValId = "";
                    mRecommendStr.clear();
                } else {
                    mCid3 = "";
                    mCategoryId = "";
                    if (!isNeedFilterValue) {
                        mPopWindow.setBrandData(new ArrayList<>());
                        mPopWindow.setSpecData(new ArrayList<>());
                        mMaterValue.clear();
                        mStr.clear();
                        brandName = "-100";
                    }
                }
                if (type == 0) {
                    mItemCid2 = secondLevel.getId();
                    loadRecommendList(false);
                } else {
                    mCategoryId = secondLevel.getId();
                    loadAllList(false);
                }
                setMatterChooseMaterialName(secondLevel);

                mBinding.rlGoodMatterChoose.setVisibility(View.GONE);
                mBinding.rvGoodMatterChoose.setVisibility(View.GONE);
                //距离
                selectPopEntity3.setCheck(false);
                mDistanceName = "";
                mBinding.sct.removeTextButtonList(moveStrings);
                moveStrings.clear();
            }

            @Override
            public void onThirdCategorizeCallBack
                    (@Nullable @org.jetbrains.annotations.Nullable MenuEntity thirdLevel, int position) {
                if (thirdLevel == null) {
                    return;
                }
                indexCid3 = position;
                String cid;
                removeBrandTextButton();
                if (type == 0) {
                    mItemCid3 = thirdLevel.getId();
                    if (mGoodsType != null && mGoodsType.size() > 1) {
                        loadRecommendList(false);
                    }
                    cid = mItemCid3;
                    mRecommendValId = "";
                    mRecommendStr.clear();
                } else {
                    if (!isNeedFilterValue) {
                        mMaterValue.clear();
                        mBrandId.clear();
                        mStr.clear();
                    }
                    mCid3 = thirdLevel.getId();
                    loadAllList(false);
                    cid = mCid3;
                }
                mBinding.rlGoodMatterChoose.setVisibility(View.VISIBLE);
                mBinding.rvGoodMatterChoose.setVisibility(View.VISIBLE);
                if (!brandName.equals(cid)) {
                    mModel.getMaterialBrand(cid);
                }
                mModel.getFilterBrandModel(cid, false);
                brandName = cid;
//                mModel.getMaterialBrand(cid);
                //距离
                selectPopEntity3.setCheck(false);
                mDistanceName = "";
            }

            @Override
            public void onSearchClickListener() {
                searchClick();
            }
        });

        initFilterView();
        mModel.getAreaData(isRegionalConnection);
        mModel.getPriceSort();
        mModel.getAreaChoose();

//        mModel.getIndustryListdata();
        if (materialHomeFragment == null) {
            materialHomeFragment = (MaterialHomeFragment1) getParentFragment();
        }
        mBinding.xrvFragmentGoodsMainGoodsList.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                loadAllList(false);
            }

            @Override
            public void onLoadMore() {
                if (type == 0) {
                    loadRecommendList(true);
                } else {
                    loadAllList(true);
                }
            }
        });
        mBinding.tvFragmentGoodsMainGoodsListSelect2.setOnClickListener(this);
        mBinding.tvFragmentGoodsMainGoodsListSelect1.setOnClickListener(this);
        mBinding.imgBackTop.setOnClickListener(this);
        mBinding.tvGoodsListScreen.setOnClickListener(this);
        LinearLayoutManager la = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false) {
            @Override
            public boolean canScrollHorizontally() {
                return false;
            }
        };
        mBinding.rvGoodMatterChoose.setLayoutManager(la);
        if (type == 0) {
            initGoodsRecommendView();
        } else {
            initAllGoodsView();
        }


        mBinding.tabIndustry.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {

                choice_Industry = tab.getPosition();
                mCid1 = choice_Industry == 0 ? null : "";
                mCategoryId = null;
                mCid3 = null;
                if (choice_Industry == 0) {
                    mBinding.categorizeView.setVisibility(View.GONE);
                    mItemCid1 = "";
                    mItemCid2 = "";
                    mItemCid3 = "";
                    mCid1 = "";
                    mCategoryId = "";
                    mCid3 = "";
                } else {
                    mModel.getMenuModel(MaterialHomeFragment1.IndustryItemlist.get(choice_Industry).getId() + "");
                }
                if (type == 0) {
                    loadRecommendList(false);
                } else {
                    loadAllList(false);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });


        if (MaterialHomeFragment1.IndustryItemlist.size() > 0) {
            showTabIndustryList();
        } else {
            mBinding.categorizeView.loadData(mGoodsType, ActivityClassHelper.getGoodsListStyle(getContext(), type).isHaveSearch(), firstCategoryId, secondCategoryId, thirdCategoryId);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEvent(MaterialEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_MATERIAL_FILTER) {
            String text = (String) event.getMessageData();
            if (mModel.materialFilterJson != null && mModel.materialFilterJson.get() != null) {
                Objects.requireNonNull(Objects.requireNonNull(mModel.materialFilterJson.get())).setText(text);
            }
            loadAllList(false);
        } else if (event.getMessageTag() == EventConstant.EVENT_GOODS_LOC) {
            mLon = (String) event.getObject();
            mLat = (String) event.getMessageData();
            if (mModel.materialFilterJson != null && mModel.materialFilterJson.get() != null) {
                Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(mModel.materialFilterJson.get())))))).setLat(mLat);
                Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(Objects.requireNonNull(mModel.materialFilterJson.get())))))).setLon(mLon);
            }
        } else if (event.getMessageTag() == EventConstant.EVENT_APPBAR_STATE_EXPANDED) {
            if (layoutParams != null) {
                isParentAppBarCollapsed = false;
            }
        } else if (event.getMessageTag() == EventConstant.EVENT_APPBAR_STATE_COLLAPSED) {
            if (layoutParams != null) {
                isParentAppBarCollapsed = true;
            }
        } else if (event.getMessageTag() == EventConstant.EVENT_APPBAR_STATE_COMMON) {
            if (layoutParams != null) {
                isParentAppBarCollapsed = false;
            }
        }
    }

    @Deprecated
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventBus(MaterialEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_NEW_TAB_VALUE && !isSelfEmployedGoods && !isPromotionalGoods) {
            List<MenuEntity> menuList = (List<MenuEntity>) event.getMessageData();
            industryPosition = (int) event.getObject();
            //showMenuView(menuList);
        } else if (event.getMessageTag() == EventConstant.EVENT_REFRESH_FRAGMENT) {
            if (type == 0) {
                loadRecommendList(false);
            } else {
                loadAllList(false);
            }
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 102 && data != null) {
            mLat = String.valueOf(data.getDoubleExtra(SelectAddressActivity.LATITUDE, 0));
            mLon = String.valueOf(data.getDoubleExtra(SelectAddressActivity.LONGTITUDE, 0));
            isRePositioning = true;
            loadAllList(false);
        }
    }


    public void locationClick() {
        Intent intent = new Intent();
        intent.setClass(requireContext(), SelectAddressActivity.class);
        intent.putExtra(SelectAddressActivity.TITLE, "选择区域");
        intent.putExtra(SelectAddressActivity.LATITUDE, Double.valueOf(mLat));
        intent.putExtra(SelectAddressActivity.LONGTITUDE, Double.valueOf(mLon));
        startActivityForResult(intent, 102);
    }

    private void initFilterView() {
        mThreeLevelPopWindow = new ThreeLevelAreaWindow(getContext()) {
            @Override
            protected void provinceClick(BaseAreaEntity baseAreaEntity, int position) {
                if (!mProvince.equals(baseAreaEntity.getId())) {
                    mCityId = "";
                }
                mProvince = baseAreaEntity.getId();
                mArea = baseAreaEntity.getSimpleName();
                if (mAreaId != null) {
                    mAreaId.clear();
                }
            }

            @Override
            protected void cityClick(BaseAreaEntity baseAreaEntity, int position) {
                if (!mCityId.equals(baseAreaEntity.getId())) {
                    if (mAreaId != null) {
                        mAreaId.clear();
                    }
                    mArea = "";
                }
                mCityId = baseAreaEntity.getId();
                mArea = baseAreaEntity.getSimpleName();
            }

            @Override
            protected void areaMoreClick(List list, int position) {
                if (mAreaId != null) {
                    mAreaId.clear();
                }
                mArea = "";
                for (Object o : list) {
                    BaseAreaEntity baseAreaEntity = (BaseAreaEntity) o;
                    if (mAreaId != null && !mAreaId.contains(baseAreaEntity.getId())) {
                        mAreaId.add(baseAreaEntity.getId());
                    }
                    if (!mArea.contains(baseAreaEntity.getSimpleName())) {
                        mArea = baseAreaEntity.getSimpleName();
                    }
                }
            }
        };
        mThreeLevelPopWindow.setShowSimpleName(true);
        mThreeLevelPopWindow.setBgView(mBinding.grayLayout);
        mThreeLevelPopWindow.setAreaMore();
        mThreeLevelPopWindow.setCitySingle();
        mThreeLevelPopWindow.setProvinceSingle();
        mThreeLevelPopWindow.setOnResultClick((key1, key2, key3) -> {
            mProvinceName = mProvince;
            if (type == 0) {
                if (mGoodsType != null && mGoodsType.size() > 1) {
                    loadRecommendList(false);
                }
            } else {
                loadAllList(false);
            }
        });
        mThreeLevelPopWindow.setOnDisMissClick(() -> {
            if (type == 0) {
                mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg);
            }
            if ("".equals(mProvinceName) || "不限".equals(mProvinceName)) {
                mBinding.sct.contentSelect(false, false, testPosition);
            } else {
                mBinding.sct.contentSelect(true, false, testPosition);
            }

        });
        distanceWindow5 = new DictWindow5(getActivity(), 1);
        distanceWindow5.setBgView(mBinding.grayLayout);
        distanceWindow5.setCheckDefaultById("");
        distanceWindow5.setVisible(type != 0);
        distanceWindow5.setOnCallBack(dictEntity -> {
            distanceId = dictEntity.getId();
            mDistanceName = dictEntity.getName();
            mModel.materialFilterJson.get().setDistance(dictEntity.getName());
            mPopWindow.setDistanceDefault(distanceWindow5.getCheckDefultPosition(dictEntity.getId()), dictEntity.getId());
            if (type == 0) {
                if (mGoodsType != null && mGoodsType.size() > 1) {
                    loadRecommendList(false);
                }
            } else {
                loadAllList(false);
            }
        });
        distanceWindow5.setOnDisMissClick(() -> {
            if (type == 0) {
                mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg);
            }
            mBinding.tvFragmentGoodsMainGoodsListSelect2.contentSelectRed(!"".equals(mDistanceName) && !"全部".equals(mDistanceName), false);
            if ("".equals(mDistanceName) || "不限".equals(mDistanceName) || "全部".equals(mDistanceName)) {
                mBinding.sct.contentSelect(false, false, testPosition);
            } else {
                mBinding.sct.contentSelect(true, false, testPosition);
            }
        });


        brandWindow5 = new DictWindow5(getActivity(), 0);
        brandWindow5.setBgView(mBinding.grayLayout);
        brandWindow5.setCheckDefaultById("");
        brandWindow5.setVisible(type != 0);
        /********************************************************************/
        brandWindow5.setOnCallBack(dictEntity -> {
            aBrandId = dictEntity.getId();
            mBrandName = dictEntity.getName();
            mBrandId.clear();
            if (!TextUtils.isEmpty(dictEntity.getId())) {
                mBrandId.add(dictEntity.getId());
            }
            mPopWindow.setBrandDefault(brandWindow5.getCheckDefultPosition(dictEntity.getId()), dictEntity.getId());
            if (type == 0) {
                if (mGoodsType != null && mGoodsType.size() > 1) {
                    loadRecommendList(false);
                }
            } else {
                loadAllList(false);
            }
        });
        brandWindow5.setOnDisMissClick(() -> {
            if (type == 0) {
                mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg);
            }
            mBinding.tvFragmentGoodsMainGoodsListSelect2.contentSelectRed(!"".equals(mBrandName) && !"全部".equals(mBrandName), false);
            if ("".equals(mBrandName) || "不限".equals(mBrandName) || "全部".equals(mBrandName)) {
                mBinding.sct.contentSelect(false, false, testPosition);
            } else {
                mBinding.sct.contentSelect(true, false, testPosition);
            }
        });

        mPopWindow = new MatterChooseMaterialFliterPopWindow3(getActivity());
        if (type == 1) {
            mPopWindow.setBgView(GoodsAggregateActivity.getCoverView());
            initPopWindowAllCover();
        }
        mPopWindow.setFilterResultClick(new MatterChooseMaterialFliterPopWindow3.FilterResultClick() {
            @Override
            public void result(MaterialFilterJson materialFilterJson, List<DictEntity3> data, SparseBooleanArray checkBooleanArray) {
                mCid1 = materialFilterJson.getmCid1();
                mAreaId = materialFilterJson.getAreaList();
                mCategoryId = materialFilterJson.getCategoryId();
                mCid3 = materialFilterJson.getItemId();
                mMaterValue = materialFilterJson.getMaterValue();
                mBrandId = materialFilterJson.getBrandId();
                if (mBrandId != null && mBrandId.size() > 0) {
                    aBrandId = mBrandId.get(0);
                } else {
                    aBrandId = "";
                }
                mDistanceName = materialFilterJson.getDistance();
                mBrandName = materialFilterJson.getBrandName();
                distanceId = materialFilterJson.getDistanceId();
                mPriceSort = String.valueOf(materialFilterJson.getPriceSort());
                isNeedFilterValue = true;
                mBinding.categorizeView.setSpecifyCategory(mCid1, mCategoryId, mCid3);
                isNeedFilterValue = false;
            }

            @Override
            public void queryTypeClassid(String id) {
                mCid1 = id;
                if (mBinding.tabIndustry.getVisibility() == View.VISIBLE && MaterialHomeFragment1.IndustryItemlist.size() > 0) {
                    if ("".equals(id)) {
                        setMatterChooseMaterialType(null);
                    } else {
                        mModel.getClassListeData(id, true);
                    }
                }
            }

            @Override
            public void queryTypeChild(String id) {
                if ("".equals(id)) {
                    setMatterChooseMaterialName(null);
                } else {
                    if (mBinding.tabIndustry.getVisibility() == View.VISIBLE && MaterialHomeFragment1.IndustryItemlist.size() > 0) {
                        mModel.getClassListeData(id, false);
                    } else if (firstMenuEntity != null && firstMenuEntity.getDatas() != null && firstMenuEntity.getDatas().size() != 0) {
                        for (int index = 0; index < firstMenuEntity.getDatas().size(); index++) {
                            MenuEntity<MenuEntity> entityMenuEntity = firstMenuEntity.getDatas().get(index);
                            if (entityMenuEntity.getId().equals(id)) {
                                setMatterChooseMaterialName(entityMenuEntity);
                                mPopWindow.setNameDefault(0, "");
                                break;
                            }
                        }
                    }
                }
            }

            @Override
            public void queryNameChild(String id) {
                //品牌
                mModel.getFilterBrandModel(id, false);
                //sku属性
                mModel.getMaterialBrand(id);
            }
        });

        mPopWindow.setOnDisMissClick(() -> EventBus.getDefault().post(LeaseEvent.make().setMessageTag(EventConstant.EVENT_SHOP_VISIBLE)));
    }

    private void initPopWindowAllCover() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            try {
                Field mLayoutInScreen = PopupWindow.class.getDeclaredField("mLayoutInScreen");
                mLayoutInScreen.setAccessible(true);
                mLayoutInScreen.set(mPopWindow, true);
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }

    public void showBrandPopWindow(List<DictEntity3> data, boolean isPopWindow) {
        if (mBrandId != null && mBrandId.size() != 0) {
            mBrandId.clear();
        }
        if (data != null && data.size() != 0) {
            DictEntity3 dictEntity3 = new DictEntity3("", "全部");
            data.add(0, dictEntity3);
        }
        mPopWindow.setBrandData(data);
        if (data != null && data.size() != 0) {
            addBrandTextButton();
        } else {
            removeBrandTextButton();
        }
        brandWindow5.setData(data);
        brandWindow5.setCheckDefaultById(aBrandId);
        if (isPopWindow) {
            EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
            new Handler().postDelayed(() -> brandWindow5.showPopwindow(mBinding.llFragmentGoodsMainGoodsListSelect, 0, 0), 300);
        }
    }

    private void removeBrandTextButton() {
        mBinding.sct.removeTextButton(brandPopEntity);
    }

    /**
     * 添加品牌筛选按钮
     */
    private void addBrandTextButton() {
        removeBrandTextButton();
        List<SelectPopEntity> selectPopEntityList = new ArrayList<>();
        selectPopEntityList.add(brandPopEntity);
        mBinding.sct.addTextButtonList(selectPopEntityList, moveStrings.size() > 0 ? moveStrings.size() : 0);

    }

    public void setDistanceData(List<DictEntity3> data, boolean isPopWindow) {
        if (matterChooseMaterialDistance.size() != 0) {
            matterChooseMaterialDistance.clear();
        }
        matterChooseMaterialDistance.addAll(data);
        mPopWindow.setDistanceData(data);
        distanceWindow5.setData(data);
        distanceWindow5.setCheckDefaultById(distanceId);
        if (isPopWindow) {
            EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
            new Handler().postDelayed(() -> distanceWindow5.showPopwindow(mBinding.llFragmentGoodsMainGoodsListSelect, 0, 0), 300);
        }
    }

    public void setMaterialBrandData(List<MaterChooseEntity> data) {
        if (mMaterValue != null && mMaterValue.size() != 0) {
            mMaterValue.clear();
        }
        this.data = data;
        if (type == 0) {
            mRecommendMatterChooseAdapter.setDatas(data);
        } else {
            mMatterChooseAdapter.setDatas(data);
        }
        mBinding.sct.removeTextButtonList(moveStrings);
        name = new String[data.size()];
        moveStrings.clear();
        List<DictEntity3> list = new ArrayList<>();
        for (MaterChooseEntity datum : data) {
            initMoveData(datum.getName());
            List<DictEntity3> list1 = new ArrayList<>();
            for (MaterChooseEntity.TypeBean typeBean : datum.getType()) {
                list1.add(new DictEntity3(typeBean.getCid(), typeBean.getCname()));
            }
            list.add(new DictEntity3(datum.getId(), datum.getName(), list1));
        }
        int leftPositon = 0;
        if (!isSelfEmployedGoods && !isPromotionalGoods) {
            leftPositon = 3;
        } else if (isSelfEmployedGoods) {
            leftPositon = 2;
        } else if (isPromotionalGoods) {
            leftPositon = 1;
        }

        mBinding.sct.addTextButtonList(moveStrings, 0);
        mPopWindow.setSpecData(list);
    }

    private void initMoveData(String name) {
        SelectPopEntity selectPopEntity = new SelectPopEntity(name, "99", false, true);
        moveStrings.add(selectPopEntity);
    }

    public void setCurrentItem(String firstCategoryId, String secondCategoryId, String thirdCategoryId) {
        mBinding.categorizeView.setSpecifyCategory(firstCategoryId, secondCategoryId, thirdCategoryId);
    }

    /**
     * 设置类别（第二级商品筛选的所有数据）
     *
     * @param firstLevel 第一级商品分类的数据
     */
    public void setMatterChooseMaterialType(MenuEntity<MenuEntity<MenuEntity>> firstLevel) {
        if (firstLevel == null || firstLevel.getDatas() == null || firstLevel.getDatas().size() == 0) {
            mPopWindow.setTypeData(null);
            return;
        }
        if (matterChooseMaterialType.size() != 0) {
            matterChooseMaterialType.clear();
        }
        for (MenuEntity<MenuEntity> menuEntity : firstLevel.getDatas()) {
            matterChooseMaterialType.add(new DictEntity3(menuEntity.getId(), menuEntity.getName()));
        }
        mPopWindow.setTypeData(matterChooseMaterialType);
    }

    /**
     * 设置品名（第三级商品筛选的所有数据）
     *
     * @param secondLevel
     */
    public void setMatterChooseMaterialName(MenuEntity<MenuEntity> secondLevel) {
        if (secondLevel == null || secondLevel.getDatas() == null || secondLevel.getDatas().size() == 0) {
            mPopWindow.setNameData(null);
            return;
        }
        if (matterChooseMaterialName.size() != 0) {
            matterChooseMaterialName.clear();
        }
        for (MenuEntity menuEntity : secondLevel.getDatas()) {
            matterChooseMaterialName.add(new DictEntity3(menuEntity.getId(), menuEntity.getName()));
        }
        mPopWindow.setNameData(matterChooseMaterialName);
    }

    @SuppressLint("NonConstantResourceId")
    @Override
    public void onMultiClick(View v) {
        switch (v.getId()) {
            case R.id.ll_self_employed:
                if (isZiYingChecked) {
                    mBinding.llSelfEmployed.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_bg));
                    mBinding.btnZiying.setTextColor(ContextCompat.getColor(requireActivity(), R.color.color_333333));
                } else {
                    mBinding.llSelfEmployed.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_new_blue_bg));
                    mBinding.btnZiying.setTextColor(ContextCompat.getColor(requireActivity(), R.color.color_main));
                }
                isZiYingChecked = !isZiYingChecked;
                if (type == 0) {
                    loadRecommendList(false);
                } else {
                    loadAllList(false);
                }
                break;
            case R.id.ll_promotional_goods:
                if (isPromotionalChecked) {
                    mBinding.llPromotionalGoods.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_bg));
                    mBinding.btnPromotionalGoods.setTextColor(ContextCompat.getColor(requireActivity(), R.color.color_333333));
                } else {
                    mBinding.llPromotionalGoods.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_new_blue_bg));
                    mBinding.btnPromotionalGoods.setTextColor(ContextCompat.getColor(requireActivity(), R.color.color_main));
                }
                isPromotionalChecked = !isPromotionalChecked;
                if (type == 0) {
                    loadRecommendList(false);
                } else {
                    loadAllList(false);
                }
                break;
            case R.id.ll_sell_goods:
                if (isSellGoodGoodsChecked) {
                    mBinding.llSellGoods.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_bg));
                    mBinding.btnSellGood.setTextColor(ContextCompat.getColor(requireActivity(), R.color.color_333333));
                } else {
                    mBinding.llSellGoods.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_new_blue_bg));
                    mBinding.btnSellGood.setTextColor(ContextCompat.getColor(requireActivity(), R.color.color_main));
                }
                isSellGoodGoodsChecked = !isSellGoodGoodsChecked;
                if (type == 0) {
                    loadRecommendList(false);
                } else {
                    loadAllList(false);
                }
                break;
            case R.id.tv_fragment_goods_main_goods_list_select2:
                mBinding.tvFragmentGoodsMainGoodsListSelect2.contentSelectRed(false, true);
                EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
                if (type == 0) {
                    mModel.getFilterDistance(mItemCid1, true);
                    mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg_2);
                } else {
                    mModel.getFilterDistance(mCid1, true);
                }
                break;
            case R.id.tv_fragment_goods_main_goods_list_select1:
                mBinding.tvFragmentGoodsMainGoodsListSelect1.contentSelectRed(false, true);
                EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
                new Handler().postDelayed(() -> mThreeLevelPopWindow.showPopwindow(mBinding.llFragmentGoodsMainGoodsListSelect, 0, 0), 300);
                if (type == 0) {
                    mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg_2);
                }
                break;
            case R.id.tv_goods_list_screen:
                EventBus.getDefault().post(LeaseEvent.make().setMessageTag(EventConstant.EVENT_SHOP_GONE));
                if (MaterialHomeFragment1.IndustryItemlist.size() > 0) {
                    if (matterChooseMaterialclassone.size() > 0) {
                        mPopWindow.setClassDefault(indexCid1, mCid1);
                    }
                    if (matterChooseMaterialType.size() > 0) {
                        mPopWindow.setTypeDefault(indexCid2, mCategoryId);
                    }
                    if (matterChooseMaterialName.size() > 0) {
                        mPopWindow.setNameDefault(indexCid3, mCid3);
                        mPopWindow.showListVisible(indexCid3);
                    }
                } else {
                    if (matterChooseMaterialType.size() > 0) {
                        mPopWindow.setTypeDefault(indexCid2, mCategoryId);
                    }
                    if (matterChooseMaterialName.size() > 0) {
                        mPopWindow.setNameDefault(indexCid3, mCid3);
                        mPopWindow.showListVisible(indexCid3);
                    }
                }
                if (matterChooseMaterialDistance.size() > 0) {
                    mPopWindow.setDistanceData(matterChooseMaterialDistance);
                } else {
                    if (!"".equals(mCid1)) {
                        mModel.getFilterDistance(mCid1, false);
                    }
                }
                if (mAreaList.size() <= 0) {
                    mModel.getAreaData(isRegionalConnection);
                }
                mPopWindow.showPopwindowRight((GoodsAggregateActivity.getPopView()));
                break;
            case R.id.img_back_top:
                mBinding.xrvFragmentGoodsMainGoodsList.smoothScrollToPosition(0);
                break;

            case R.id.iv_quick_entry:

                if (quickEntryPopWindow == null) {
                    quickEntryPopWindow = new QuickEntryPopWindow(getActivity());
                    //必须调用
                    quickEntryPopWindow.setListener(this::onItemClick);
                }
                quickEntryPopWindow.backgroundAlpha(0.5f);
                quickEntryPopWindow.setRecover();
                quickEntryPopWindow.showPopwindowLeft(mBinding.ivQuickEntry);

//                goodsNavigationAdapter.notifyDataSetChanged();
            default:
                break;
        }
    }

    private void loadRecommendList(boolean isLoadMore) {
        isLoadMoreRecommendGoodsList = isLoadMore;
        mRecommendPageNum = isLoadMore ? mRecommendPageNum + 1 : 1;
        StringBuilder stringBuilder = new StringBuilder();
        if (mAreaId != null && mAreaId.size() != 0) {
            for (String s : mAreaId) {
                stringBuilder.append(",").append(s);
            }
        }
        stringBuilder.replace(0, 1, "");
        Map<String, Object> map = new HashMap<>();
        map.put("province", mProvince);
        map.put("city", mCityId);
        map.put("area", stringBuilder.toString());
        map.put("page", mRecommendPageNum);
        map.put("limit", 10);
        map.put("valId", mRecommendValId);
        if (!TextUtils.isEmpty(mItemCid1)) {
            map.put("item_cid1", mItemCid1);
        }
        if (!TextUtils.isEmpty(mItemCid2)) {
            map.put("item_cid2", mItemCid2);
        }
        if (!TextUtils.isEmpty(mItemCid3)) {
            map.put("item_cid", mItemCid3);
        }

        if ("".equals(mItemCid3)) {
            map.put("brandId", "");
        } else {
            if (mBrandId.size() > 0) {
                map.put("brandId", mBrandId.get(0));
            } else {
                map.put("brandId", "");
            }
        }
        if (LocationUtil.isOpenLocation(getContext()) && LocationUtil.currentLocationIsValid()) {
            map.put("lon", String.valueOf(LocationUtil.getCurrentLongitude()));
            map.put("lat", String.valueOf(LocationUtil.getCurrentLatitude()));
        } else {
            map.put("lon", "0");
            map.put("lat", "0");
        }
        if (MaterialHomeFragment1.IndustryItemlist.size() > 0) {
            if (choice_Industry != 0 && choice_Industry != -1 && TextUtils.isEmpty(mItemCid1)) {
                map.put("industryId", MaterialHomeFragment1.IndustryItemlist.get(choice_Industry).getId());
            }
        }
        if (isSelfEmployedGoods) {
            map.put("selfSupportTag", 1);
            if (isPromotionalChecked) {
                map.put("promoteStatus", 2);
            }
            if (isSellGoodGoodsChecked) {
                map.put("bestSellers", 1);
            } else {
                map.put("bestSellers", 0);
            }
            mModel.getSelfSupportMaterialsList(map);
        } else if (isPromotionalGoods) {
            if (isZiYingChecked) {
                map.put("selfSupportTag", 1);
            }
            mModel.getPromotionsList(map);
        } else {
            if (isZiYingChecked) {
                map.put("selfSupportTag", 1);
            }
            if (isPromotionalChecked) {
                map.put("promoteStatus", 2);
            }
            mModel.getRecommendList(map);
        }


    }

    private void loadAllList(boolean isLoadMore) {
        isLoadMoreGoodsList = isLoadMore;
        mPageNum = isLoadMore ? mPageNum + 1 : 1;
        if ("7".equals(mCid1)) {
            Map<String, Object> map = new HashMap<>();
            map.put("pageNum", mPageNum);
            map.put("pageSize", 20);
            map.put("distance", mDistanceName);
            map.put("priceSort", mPriceSort);
            if (!"0".equals(mPriceSort)) {
                map.put("timeSort", "0");
            } else {
                map.put("timeSort", "2");
            }
            if (!TextUtils.isEmpty(mCid1)) {
                map.put("cid1", mCid1);
            }
            if (!TextUtils.isEmpty(mCategoryId)) {
                map.put("categoryId", mCategoryId);
            }
            if (!TextUtils.isEmpty(mCid3)) {
                map.put("cid3", mCid3);
            }
            String mItemId = "";
            map.put("itemId", mItemId);
            if ("".equals(mCid3)) {
                map.put("brandId", brandId);
            } else {
                map.put("brandId", mBrandId);
            }
            map.put("materValue", mMaterValue);//属性
            map.put("regionCode", mAreaId);
            map.put("areaId", mCityId);//地区
            map.put("areaCode", mProvince);
            if (isZiYingChecked || isSelfEmployedGoods) {
                map.put("selfSupport", "1");
            }
            if (isPromotionalGoods || isPromotionalChecked) {
                map.put("promoteStatus", 2);
            }
            if (isSellGoodGoodsChecked) {
                map.put("bestSellers", 1);
            } else {
                map.put("bestSellers", 0);
            }
            if (LocationUtil.isOpenLocation(getContext()) && LocationUtil.currentLocationIsValid()) {
                if (!isRePositioning) {
                    map.put("lon", String.valueOf(LocationUtil.getCurrentLongitude()));
                    map.put("lat", String.valueOf(LocationUtil.getCurrentLatitude()));
                } else {
                    map.put("lon", mLon);
                    map.put("lat", mLat);
                }
            } else {
                map.put("lon", "0");
                map.put("lat", "0");
            }
            mModel.getConcreteList(map);
        } else {
            Map<String, Object> map = new HashMap<>();
            map.put("pageNum", mPageNum);
            map.put("pageSize", 20);
            map.put("distance", mDistanceName);
            map.put("priceSort", mPriceSort);//价格排序
            if (!"0".equals(mPriceSort)) {
                map.put("timeSort", "0");
            } else {
                map.put("timeSort", "2");
            }
            if (!TextUtils.isEmpty(mCid1)) {
                map.put("cid1", mCid1);
            }
            if (!TextUtils.isEmpty(mCategoryId)) {
                map.put("categoryId", mCategoryId);
            }
            if (!TextUtils.isEmpty(mCid3)) {
                map.put("cid3", mCid3);
            }
            String mItemId = "";
            map.put("itemId", mItemId);
            if ("".equals(mCid3)) {
                map.put("brandId", brandId);
            } else {
                map.put("brandId", mBrandId);
            }
            map.put("materValue", mMaterValue.size() == 0 ? "" : StringUtil.formatListToString(mMaterValue));//属性
            map.put("regionCode", mAreaId);
            map.put("areaId", mCityId);
            map.put("areaCode", mProvince);
            if (isZiYingChecked || isSelfEmployedGoods) {
                map.put("selfSupportTag", 1);
            }
            if (isPromotionalGoods || isPromotionalChecked) {
                map.put("promoteStatus", 2);
            }
            if (isSellGoodGoodsChecked) {
                map.put("bestSellers", 1);
            } else {
                map.put("bestSellers", 0);
            }
            if (isHuiYuanChecked) {
                map.put("isMemberPrice", 1);
            }
            if (LocationUtil.isOpenLocation(getContext()) && LocationUtil.currentLocationIsValid()) {
                if (!isRePositioning) {
                    map.put("lon", String.valueOf(LocationUtil.getCurrentLongitude()));
                    map.put("lat", String.valueOf(LocationUtil.getCurrentLatitude()));
                } else {
                    map.put("lon", mLon);
                    map.put("lat", mLat);
                }
            } else {
                map.put("lon", "0");
                map.put("lat", "0");
            }
            if (MaterialHomeFragment1.IndustryItemlist.size() > 0) {
                if (choice_Industry != 0 && choice_Industry != -1 && TextUtils.isEmpty(mCid1)) {
                    map.put("industryId", MaterialHomeFragment1.IndustryItemlist.get(choice_Industry).getId());
                }
            }
            Log.e("message", new Gson().toJson(map));
            mModel.getGoodsList(map);
        }
    }

    public static void setMargins(View v, int l, int t, int r, int b) {
        if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
            p.setMargins(l, t, r, b);
            v.requestLayout();
        }
    }

    public void getConcreteList(List<ConcreteEntity> dataA) {
        List<GoodsListEntity> data = new ArrayList<>();
        for (ConcreteEntity concreteEntity : dataA) {
            data.add(new GoodsListEntity(true, "", concreteEntity.getDistance(), concreteEntity.getSelfSupportTag(), concreteEntity.getProviderName(), concreteEntity.getTitle(), 0, "", concreteEntity.getImage(), concreteEntity.getUnit(), concreteEntity.getCompanyNo()
                    , concreteEntity.getPrice(), "", concreteEntity.getId(), "", "", "", "", "", concreteEntity.getSort(), false, concreteEntity.getRanking(), concreteEntity.getStorageName(), concreteEntity.getLon(), concreteEntity.getLat(), concreteEntity.getLowestBuy(), concreteEntity.getImAccount()));
        }
        mBinding.xrvFragmentGoodsMainGoodsList.refreshComplete();
        if (isLoadMoreGoodsList) {
            if (data.size() > 0) {
                mBinding.xrvFragmentGoodsMainGoodsList.loadMoreComplete();
                mMaterialAdapter.addDatas(data);
            } else {
                mBinding.xrvFragmentGoodsMainGoodsList.setNoMore(true);
            }
            mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.VISIBLE);
        } else {
            mBinding.xrvFragmentGoodsMainGoodsList.refreshComplete();
            if (data.size() > 0) {
                mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.VISIBLE);
                mBinding.flContainer.setVisibility(View.GONE);
                mBinding.emptyView.setVisibility(View.GONE);
                mMaterialAdapter.setDatas(data);
                mBinding.xrvFragmentGoodsMainGoodsList.setLoadingMoreEnabled(true);
            } else {
                mMaterialAdapter.setDatas(null);
                mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.GONE);
                mBinding.flContainer.setVisibility(View.VISIBLE);
                mBinding.emptyView.setVisibility(View.VISIBLE);
            }
        }
    }

    public void showTabIndustryList() {

        mBinding.tabIndustry.setVisibility(View.VISIBLE);
        mBinding.tabIndustry.removeAllTabs();
        for (int i = 0; i < MaterialHomeFragment1.IndustryItemlist.size(); i++) {
            if (TextUtils.isEmpty(hyid)) {
                choice_Industry = 0;
            } else {
                if (hyid.equals(MaterialHomeFragment1.IndustryItemlist.get(i).getId() + "")) {
                    choice_Industry = i;
                }
            }
            mBinding.tabIndustry.addTab(mBinding.tabIndustry.newTab().setText(MaterialHomeFragment1.IndustryItemlist.get(i).getName()), choice_Industry == i);
        }
        if (!TextUtils.isEmpty(hyid) && Integer.parseInt(hyid) > 0 && choice_Industry == 0) {
            mBinding.tabIndustry.setVisibility(View.GONE);
            return;
        }
        if (choice_Industry != 0) {
            mModel.getMenuModel(MaterialHomeFragment1.IndustryItemlist.get(choice_Industry).getId() + "");
            loadAllList(false);
        } else {
            if (type == 0) {
                loadRecommendList(false);
            } else {
                loadAllList(false);
            }
            mBinding.categorizeView.setVisibility(View.GONE);
        }
        mBinding.tabIndustry.postDelayed(new Runnable() {
            @Override
            public void run() {
                mBinding.tabIndustry.getTabAt(choice_Industry).select();
            }
        }, 100);

    }

    public void getRecommendList(List<RecommendListEntity> data) {
        if (isLoadMoreRecommendGoodsList) {
            if (null != data && data.size() > 0) {
                mBinding.xrvFragmentGoodsMainGoodsList.loadMoreComplete();
                mRecommendGoodsAdapter.addDatas(data);
            } else {
                mBinding.xrvFragmentGoodsMainGoodsList.setNoMore(true);
            }
            mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.VISIBLE);
        } else {
            mBinding.xrvFragmentGoodsMainGoodsList.refreshComplete();
            if (null != data && data.size() > 0) {
                mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.VISIBLE);
                mBinding.flContainer.setVisibility(View.GONE);
                mBinding.emptyView.setVisibility(View.GONE);
                mRecommendGoodsAdapter.setDatas(data);
                mBinding.xrvFragmentGoodsMainGoodsList.setLoadingMoreEnabled(true);
            } else {
                mRecommendGoodsAdapter.setDatas(null);
                mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.GONE);
                mBinding.flContainer.setVisibility(View.VISIBLE);
                mBinding.emptyView.setVisibility(View.VISIBLE);
            }
        }
    }

    @Deprecated
    private void setTextViewBg(TextView textView, int bg, int img, int textColor) {
        Drawable drawable_n = ContextCompat.getDrawable(getContext(), img);
        drawable_n.setBounds(0, 0, drawable_n.getMinimumWidth(), drawable_n.getMinimumHeight());  //此为必须写的
        textView.setCompoundDrawables(null, null, drawable_n, null);
        textView.setTextColor(ContextCompat.getColor(getContext(), textColor));
    }

    @Deprecated
    public void getItemChoose(List<DictEntity3> data) {
        mPopWindow.setSpecData(data);
    }

    public void setAddressData(List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> data, String areaCode) {
        this.mAreaList = data;
        mThreeLevelPopWindow.setData(data, true, areaCode);
    }

    public void showPriceSort(List<DictEntity3> list) {
        mPopWindow.setPriceData(list);
    }

    /**
     * 地区
     *
     * @param list
     */
    public void getAreaChoose(List<AreaChooseEntity> list) {
        if (list == null || list.size() == 0) {
            return;
        }
        if (matterChooseMaterialArea.size() != 0) {
            matterChooseMaterialArea.clear();
        }
        for (AreaChooseEntity areaChooseEntity : list) {
            matterChooseMaterialArea.add(new DictEntity3(areaChooseEntity.getId(), areaChooseEntity.getAreaName()));
        }
        mPopWindow.setAreaData(matterChooseMaterialArea);
    }

    public void getGoodsList(List<GoodsListEntity> data) {
        mBinding.xrvFragmentGoodsMainGoodsList.refreshComplete();
        if (isLoadMoreGoodsList) {
            if (null != data && data.size() > 0) {
                mBinding.xrvFragmentGoodsMainGoodsList.loadMoreComplete();
                if (mMaterialAdapter != null) {
                    mMaterialAdapter.addDatas(data);
                }
            } else {
                mBinding.xrvFragmentGoodsMainGoodsList.setNoMore(true);
            }
            mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.VISIBLE);
        } else {
            mBinding.xrvFragmentGoodsMainGoodsList.refreshComplete();
            if (null != data && data.size() > 0) {
                mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.VISIBLE);
                mBinding.flContainer.setVisibility(View.GONE);
                mBinding.emptyView.setVisibility(View.GONE);
                if (mMaterialAdapter != null) {
                    mMaterialAdapter.setDatas(data);
                }
                mBinding.xrvFragmentGoodsMainGoodsList.setLoadingMoreEnabled(true);
            } else {
                if (mMaterialAdapter != null) {
                    mMaterialAdapter.setDatas(null);
                }
                mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.GONE);
                mBinding.flContainer.setVisibility(View.VISIBLE);
                mBinding.emptyView.setVisibility(View.VISIBLE);
            }
        }
    }

    private void initGoodsRecommendView() {
        sbl = new StringBuilder();
        for (MenuEntity<MenuEntity<MenuEntity>> menuEntity : mGoodsType) {
            if (!"全部".equals(menuEntity.getName())) {
                sbl.append(",").append(menuEntity.getId());
            }
        }
        if (sbl.length() > 0) {
            sbl.replace(0, 1, "");
        }
        mBinding.xrvFragmentGoodsMainGoodsList.setLayoutManager(new GridLayoutManager(getContext(), 2));
        mRecommendGoodsAdapter = new RecommendGoodsAdapter(getContext(), null);
        mBinding.xrvFragmentGoodsMainGoodsList.setAdapter(mRecommendGoodsAdapter);
        initStickView();
        mRecommendGoodsAdapter.setmResembleGoodsClick(recommendListEntity -> {
            if (isSelfEmployedGoods) {
                materialHomeFragment.startForResemble(recommendListEntity.getCid1(), recommendListEntity.getCid2(), recommendListEntity.getCid(), 1);
            } else if (isPromotionalGoods) {
                materialHomeFragment.startForResemble(recommendListEntity.getCid1(), recommendListEntity.getCid2(), recommendListEntity.getCid(), 3);
            } else {
                materialHomeFragment.startForResemble(recommendListEntity.getCid1(), recommendListEntity.getCid2(), recommendListEntity.getCid(), 0);
            }
        });
        mRecommendGoodsAdapter.setOnItemClick(new AdapterOnItemClick<RecommendListEntity>() {
            @Override
            public void onItemClick(RecommendListEntity recommendListEntity, int position) {
                if ("7".equals(mGoodsType.get(indexCid1).getId())) {
                    ConcreteDetailActivity2.start(getActivity(), recommendListEntity.getId());
                } else {
                    ShopGoodsDetailActivity.start(getContext(), recommendListEntity.getId(), "", recommendListEntity.getSkuid());
                }
            }
        });

        if (mGoodsType != null && mGoodsType.size() > 1) {

        } else {
            if (mRecommendGoodsAdapter != null) {
                mRecommendGoodsAdapter.setDatas(null);
            }
            mBinding.xrvFragmentGoodsMainGoodsList.setVisibility(View.GONE);
            mBinding.flContainer.setVisibility(View.VISIBLE);
            mBinding.emptyView.setVisibility(View.VISIBLE);
        }

        mBinding.xrvFragmentGoodsMainGoodsList.setPullRefreshEnabled(false);
        mBinding.xrvFragmentGoodsMainGoodsList.setOverScrollMode(View.OVER_SCROLL_NEVER);
        mRecommendMatterChooseAdapter = new RecommendMatterChooseAdapter(getContext(), null);
        mBinding.rvGoodMatterChoose.setAdapter(mRecommendMatterChooseAdapter);
        mRecommendMatterChooseAdapter.setmMatterChoose((entity, select) -> {
            select.contentSelectRed(false, true);
            StringBuilder mList = new StringBuilder();
            final String[] name = {""};
            MatterChooseWindow mNameWindow5 = new MatterChooseWindow(getContext());
            boolean isChange = false;

            mNameWindow5.setVisible(true);
            mNameWindow5.setOnCloseBack(() -> {
                select.contentSelectRed(!"全部".equals(name[0]), false);
            });

            if (type == 0) {
                mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg_2);
            }

            mNameWindow5.setOnCallBack(dictEntity -> {
                mRecommendStr.put(entity.getName(), dictEntity);
                for (MaterChooseEntity.TypeBean value : mRecommendStr.values()) {
                    mList.append(",").append(value.getCid());
                }
                mList.replace(0, 1, "");
                name[0] = dictEntity.getCname();

                mRecommendValId = mList.toString();
                if (mGoodsType != null && mGoodsType.size() > 1) {
                    loadRecommendList(false);
                }
            });

            mNameWindow5.setOnDisMissClick(() -> mBinding.rlGoodsMainGoodsListTab.setBackgroundResource(R.drawable.attestation_text_bg));
            mNameWindow5.setData(entity.getType());
            mNameWindow5.setBgView(mBinding.grayLayout);
            for (String s : mRecommendStr.keySet()) {
                if (entity.getName().equals(s)) {
                    mNameWindow5.setCheckDefaultById(Objects.requireNonNull(Objects.requireNonNull(mRecommendStr.get(s))).getCid());
                    isChange = true;
                    break;
                } else {
                    isChange = false;
                }
            }
            if (!isChange) {
                mNameWindow5.setCheckDefaultById(entity.getType().get(0).getCid());
            }
            EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
            new Handler().postDelayed(() -> mNameWindow5.showPopwindow(mBinding.llFragmentGoodsMainGoodsListSelect, 0, 0), 300);
        });
    }

    /****
     * 初始化置顶监听
     */
    private void initStickView() {
        mBinding.appBar.addOnOffsetChangedListener(new AppBarStateChangeListener() {
            @Override
            public void onStateChanged(AppBarLayout appBarLayout, State state) {
                isAppBarExpended = state == State.EXPANDED;
            }
        });

        mBinding.appBar.post(() -> {
            CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) mBinding.appBar.getLayoutParams();
            AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) layoutParams.getBehavior();
            if (behavior == null) {
                return;
            }
            int topAndBottomOffset = behavior.getTopAndBottomOffset();
            if (topAndBottomOffset != 0) {
                behavior.setTopAndBottomOffset(0);
                mBinding.appBar.setExpanded(true, true);
            }
        });

        final GridLayoutManager gridLayoutManager = (GridLayoutManager) mBinding.xrvFragmentGoodsMainGoodsList.getLayoutManager();

        mBinding.xrvFragmentGoodsMainGoodsList.addOnScrollListener(new RecyclerView.OnScrollListener() {
            //只在状态改变时调用
            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                if (gridLayoutManager != null) {
                    int completelyVisibleItemPosition = gridLayoutManager.findFirstCompletelyVisibleItemPosition();
                    if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                        if (completelyVisibleItemPosition == 0) {
                            if (!isParentAppBarCollapsed) {
                                layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                            } else {
                                if (isAppBarExpended) {
                                    if (!isUpDragging) {//向下拖拽
                                        layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                                    } else { //向上拖拽
                                        layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
                                    }
                                } else {
                                    layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
                                }
                            }
                            mBinding.rlGoodsMainGoodsListTab.setLayoutParams(layoutParams);
                            mBinding.rlGoodsMainGoodsListTab.requestLayout();
                        } else {
                            if (isParentAppBarCollapsed && isAppBarExpended) {
                                if (isUpDragging) {
                                    layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
                                } else {
                                    layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                                }
                                mBinding.rlGoodsMainGoodsListTab.setLayoutParams(layoutParams);
                                mBinding.rlGoodsMainGoodsListTab.requestLayout();
                            }
                        }
                    }
                }
            }

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (dy > 0) {
                    if (isParentAppBarCollapsed) {
                        if (isAppBarExpended) {
                            if (isUpDragging) {
                                layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
                            } else {
                                if (layoutParams.getScrollFlags() != FLAG_NO_SCROLL) {
                                    layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                                } else {
                                    layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
                                }
                            }
                            mBinding.rlGoodsMainGoodsListTab.setLayoutParams(layoutParams);
                            mBinding.rlGoodsMainGoodsListTab.requestLayout();
                        }
                    } else {
                        if (layoutParams.getScrollFlags() != FLAG_NO_SCROLL) {
                            layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                            mBinding.rlGoodsMainGoodsListTab.setLayoutParams(layoutParams);
                            mBinding.rlGoodsMainGoodsListTab.requestLayout();
                        }
                    }
                    isUpDragging = true;
                } else if (dy < 0) {
                    if (isParentAppBarCollapsed) {
                        if (isAppBarExpended) {
                            if (!isUpDragging) {
                                if (layoutParams.getScrollFlags() != FLAG_NO_SCROLL) {
                                    layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                                    mBinding.rlGoodsMainGoodsListTab.setLayoutParams(layoutParams);
                                    mBinding.rlGoodsMainGoodsListTab.requestLayout();
                                }
                            } else {
                                if (layoutParams.getScrollFlags() != FLAG_NO_SCROLL) {
                                    layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                                } else {
                                    layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
                                }
                                mBinding.rlGoodsMainGoodsListTab.setLayoutParams(layoutParams);
                                mBinding.rlGoodsMainGoodsListTab.requestLayout();
                            }
                        }
                    } else {
                        if (layoutParams.getScrollFlags() != FLAG_NO_SCROLL) {
                            layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                            mBinding.rlGoodsMainGoodsListTab.setLayoutParams(layoutParams);
                            mBinding.rlGoodsMainGoodsListTab.requestLayout();
                        }
                    }
                    isUpDragging = false;
                }
            }
        });
    }

    private void initAllGoodsView() {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        mBinding.xrvFragmentGoodsMainGoodsList.setLayoutManager(linearLayoutManager);
        mMaterialAdapter = new MaterialAdapter(getContext(), null, false);
        mBinding.xrvFragmentGoodsMainGoodsList.setAdapter(mMaterialAdapter);
        mMaterialAdapter.setOnItemClick(new AdapterOnItemClick<GoodsListEntity>() {
            @Override
            public void onItemClick(GoodsListEntity goodsListEntity, int position) {
                if (MaterialHomeFragment1.IndustryItemlist.size() > 0) {
                    if (classlistone.size() > 0 && "7".equals(classlistone.get(indexCid1).getId())) {
                        MaterialFilterJson filterJson = new MaterialFilterJson();
                        filterJson.setStrengthId(goodsListEntity.getSort());
                        ConcreteDetailActivity2.start(getActivity(), goodsListEntity.getId(), filterJson);
                    } else {
                        ShopGoodsDetailActivity.start(getContext(), goodsListEntity.getId(), "", goodsListEntity.getSkuid());
                    }
                } else {
                    if (mGoodsType.size() > 0 && "7".equals(mGoodsType.get(indexCid1).getId())) {
                        MaterialFilterJson filterJson = new MaterialFilterJson();
                        filterJson.setStrengthId(goodsListEntity.getSort());
                        ConcreteDetailActivity2.start(getActivity(), goodsListEntity.getId(), filterJson);
                    } else {
                        ShopGoodsDetailActivity.start(getContext(), goodsListEntity.getId(), "", goodsListEntity.getSkuid());
                    }
                }
            }
        });
        mBinding.xrvFragmentGoodsMainGoodsList.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
            }

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (linearLayoutManager.findFirstVisibleItemPosition() > 1) {
                    mBinding.imgBackTop.setVisibility(View.VISIBLE);
                } else {
                    mBinding.imgBackTop.setVisibility(View.GONE);
                }
            }
        });

        mMatterChooseAdapter = new MatterChooseAdapter(getContext(), null);
        mBinding.rvGoodMatterChoose.setAdapter(mMatterChooseAdapter);
        mMatterChooseAdapter.setmMatterChoose((entity, select) -> {
            select.contentSelectRed(false, true);
            List<String> mList = new ArrayList<>();
            final String[] name = {""};
            boolean isChange = false;
            MatterChooseWindow mNameWindow5 = new MatterChooseWindow(getContext());

            mNameWindow5.setVisible(false);
            mNameWindow5.setOnCloseBack(() -> {
                if (!"".equals(name[0])) {
                    select.contentSelectRed(true, true);
                } else {
                    select.contentSelectRed(false, false);
                }
            });

            mNameWindow5.setOnCallBack(dictEntity -> {
                mStr.put(entity.getName(), dictEntity);
                for (MaterChooseEntity.TypeBean value : mStr.values()) {
                    if (!"".equals(value.getCid())) {
                        mList.add(value.getCname());
                    }
                }

                name[0] = dictEntity.getCname();
                mMaterValue = mList;
                loadAllList(false);
            });

            mNameWindow5.setData(entity.getType());
            mNameWindow5.setBgView(mBinding.grayLayout);
            for (String s : mStr.keySet()) {
                if (entity.getName().equals(s)) {
                    mNameWindow5.setCheckDefaultById(mStr.get(s).getCid());
                    isChange = true;
                    break;
                } else {
                    isChange = false;
                }
            }

            if (!isChange) {
                mNameWindow5.setCheckDefaultById(entity.getType().get(0).getCid());
            }
            EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
            new Handler().postDelayed(() -> mNameWindow5.showPopwindow(mBinding.llFragmentGoodsMainGoodsListSelect, 0, 0), 300);
        });

    }

    private void searchClick() {
        if (isSelfEmployedGoods) {
            HomeCategoryActivity.start(getActivity(), RequestCode.REQUEST_SHOP_SELFEMPLOYED);
        } else {
            HomeCategoryActivity.start(getActivity(), RequestCode.REQUEST_SHOP);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEvent(ChooseAreaEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_CHOOSE_AERA && isRegionalConnection) {
            ProvinceEntity<List<ProvinceEntity>> list = (ProvinceEntity<List<ProvinceEntity>>) event.getMessageData();
            if (mThreeLevelPopWindow != null && this.mAreaList != null && list != null) {
                mThreeLevelPopWindow.setData(this.mAreaList, true, String.valueOf(list.getId()));
                mProvince = String.valueOf(list.getId());
                mCityId = "";
                if (mAreaId != null) {
                    mAreaId.clear();
                }
                loadRecommendList(false);
            }
        } else if (event.getMessageTag() == EventConstant.EVENT_LOGIN_REF) {
            mBinding.sct.removeAllTextButton();
            isPromotionalChecked = false;
            isZiYingChecked = false;
            isSellGoodGoodsChecked = false;
            isHuiYuanChecked = false;
            setTextButton();
            if (type == 0) {
                loadRecommendList(false);
            } else {
                loadAllList(false);
            }
        } else if (event.getMessageTag() == EventConstant.EVENT_MENU_DEVICE_OUT) {
            mBinding.sct.removeAllTextButton();
            isPromotionalChecked = false;
            isZiYingChecked = false;
            isSellGoodGoodsChecked = false;
            isHuiYuanChecked = false;
            setTextButton();
            if (type == 0) {
                loadRecommendList(false);
            } else {
                loadAllList(false);
            }
        }
    }

    public String getCid1() {
        return sbl.toString();
    }

    public void setParentFragment(AppFragment appFragment) {
        if (appFragment instanceof MaterialHomeFragment1) {
            materialHomeFragment = (MaterialHomeFragment1) appFragment;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    private void setTextButton() {
        if (!isSelfEmployedGoods) {
            SelectPopEntity selectPopEntity1 = new SelectPopEntity("自营", "1", false, false);
            mBinding.sct.addTextButton(selectPopEntity1);
        }
        if (!isPromotionalGoods) {
            SelectPopEntity selectCuXiao = new SelectPopEntity("促销", "2", false, false);
            SelectPopEntity selectReXiao = new SelectPopEntity("热销", "3", false, false);
            mBinding.sct.addTextButton(selectCuXiao);
            mBinding.sct.addTextButton(selectReXiao);
        }
        //如果该登录身份是企业，则显示会员筛选
        // TODO 1.4.9 后台和产品沟通需要重新写接口商品首页推荐列表暂不作会员价筛选功能
        if (1 == SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0) && UserOperating.getInstance().isLogged() && type == 1) {
            selectHuiYuan = new SelectPopEntity("会员价", "7", false, false);
            mBinding.sct.addTextButton(selectHuiYuan);
        }

        SelectPopEntity selectPopEntity2 = new SelectPopEntity("仓储地", "4", false, true);
        selectPopEntity3 = new SelectPopEntity("距离", "5", false, true);
        brandPopEntity = new SelectPopEntity("品牌", "6", false, true);
        mBinding.sct.addTextButton(selectPopEntity2);
        mBinding.sct.contentSelect(false, false, testPosition);
    }

    private List<MenuEntity> classlistone = new ArrayList<>();

    public void showecommendCategoryData(List<MenuEntity> data) {
        classlistone.clear();
        if (data.size() > 0) {
            classlistone.addAll(data);
            mBinding.categorizeView.setVisibility(View.VISIBLE);
            showPopWindowClassOne(data);
            mBinding.categorizeView.loadDataNew(data, ActivityClassHelper.getGoodsListStyle(getContext(), type).isHaveSearch(), firstCategoryId, secondCategoryId, thirdCategoryId, mModel.getAreaCode());
        } else {
            showPopWindowClassOne(new ArrayList<>());
            mBinding.categorizeView.setVisibility(View.GONE);
            return;
        }
    }

    public void showPopWindowClassOne(List<MenuEntity> data) {
        if (data == null || data.size() == 0) {
            mPopWindow.setGoodsClassList(null);
            return;
        }
        if (matterChooseMaterialclassone.size() != 0) {
            matterChooseMaterialclassone.clear();
        }
        for (MenuEntity datum : data) {
            DictEntity3 mdata = new DictEntity3();
            mdata.setId(datum.getId());
            mdata.setName(datum.getName());
            matterChooseMaterialclassone.add(mdata);
        }

        mPopWindow.setGoodsClassList(matterChooseMaterialclassone);
    }

    @Override
    public void onItemClick(QuickEntryEntity entity) {
        changeTabFragmentEvent(entity.getId());
        switch (entity.getId()) {
            case "0": //首页/网站推荐
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 21));
                break;
            case "1": //商品/销售
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 1));
                break;
            case "1-1": //全部商品
                if (titleData == null) {
                    mModel.recommendMenu(0, false);
                } else {
                    showImageButtonData(titleData, 0, false);
                }
                break;
            case "1-2": //自营商品
                if (titleData == null) {
                    mModel.recommendMenu(1, false);
                } else {
                    showImageButtonData(titleData, 1, false);
                }
                break;
            case "1-3": //集采商品
                if (titleData == null) {
                    mModel.recommendMenu(2, false);
                } else {
                    showImageButtonData(titleData, 2, false);
                }
                break;
            case "1-4": //促销商品
                if (titleData == null) {
                    mModel.recommendMenu(3, false);
                } else {
                    showImageButtonData(titleData, 3, false);
                }
                break;
            case "1-5": //供应商
                if (titleData == null) {
                    mModel.recommendMenu(5, false);
                } else {
                    showImageButtonData(titleData, 5, false);
                }
                break;
            case "2": //招标竞价
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 2));
                break;
            case "2-1": //招标大厅
                PickListActivity.start(getActivity(), "1", 0);
                break;
            case "2-2": //招标公告
                PickListActivity.start(getActivity(), "2", 0);
                break;
            case "2-3": //直接竞价
                PickBiddingListActivity.start(getActivity());
                break;
            case "2-4": //需求预告
                DemandForecastActivity.start(getActivity());
                break;
            case "2-5": //招标预告
                PickNoticeActivity.start(getActivity());
                break;
            case "2-6": //中标公告
                PickWinningNoticeActivity.start(getActivity());
                break;
            case "3": //集采团购
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 3));
                break;
            case "3-1": //集采大厅
                JiCaiDaTingActivity.start(getActivity());
                break;
            case "3-2": //需方发起
                XuFangFaQiActivity.start(getActivity(), "1");
                break;
            case "3-3": //供方发起
                FactoryCentralizedActivity.start(getActivity());
                break;
            case "3-4": //企业专项
                XuFangFaQiActivity.start(getActivity(), "2");
                break;
            case "3-5": //我的加盟
                if (!TextUtils.isEmpty(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    MyCenterMyJoinActivity.start(getActivity());
                } else {
                    VerificationCodeLoginActivity.start(getActivity());
                }
                break;
            case "3-6": //我的报价
                if (!TextUtils.isEmpty(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    JcMyPriceActivity.start(getActivity());
                } else {
                    VerificationCodeLoginActivity.start(getActivity());
                }
                break;
            case "4": //租赁转让
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 4));
                break;
            case "4-1": //出租大厅
                LeaseHallActivity2.start(getActivity());
                break;
            case "4-2": //需求大厅
                LeaseHallActivity2.start(getActivity(), 1, 0);
                break;
            case "5": //工队工人
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 5));
                break;
            case "5-1": //临时用工
                //临时用工-工队首页点击用工需求
                //"用工需求","工人大厅","工队大厅","工种报价","工程分包","工程公司","人气工队"
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity, Pair.create("type", 0));
                break;
            case "5-2": //找工人
                //找工人-工队首页点击个人大厅
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity, Pair.create("type", 1));
                break;
            case "5-3": //施工队
                //施工队，班组工队，劳务公司-工队首页点击工队大厅 {"施工队", "班组工队", "劳务公司", "记工记账"};
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity, Pair.create("type", 2));
                break;
            case "5-4": //班组工队
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,
                        Pair.create("type", 2), Pair.create("childPosition", 1));
                break;
            case "5-5": //工程公司
                //"用工需求","工人大厅","工队大厅","工种报价","工程分包","工程公司","人气工队"
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,
                        Pair.create("type", 5));
                break;
            case "5-6": //劳务公司 -工队首页点击工队大厅
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,
                        Pair.create("type", 2), Pair.create("childPosition", 2));
                break;
            case "5-7": //工种报价
                //"用工需求","工人大厅","工队大厅","工种报价","工程分包","工程公司","人气工队"
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity, Pair.create("type", 3));
                break;
            case "6": //物流货运
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 6));
                break;
            case "6-1": //货运大厅
                GoodsCarsActivity.start(getActivity(), 0, false);
                break;
            case "6-2": //货车大厅
                GoodsCarsActivity.start(getActivity(), 1, true);
                break;
            case "6-3": //竞价货运
                BiddingTransportHallActivity.start(getContext());
                break;
            case "6-4": //竞价承运
                DriverLookForGoodsActivity.start(getContext());
                break;
            case "7": //企业服务
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 22));
                break;
            case "7-1": //服务大厅
                ProfessionalQuoteActivity.start(getActivity());
                break;
            case "7-2": //需求大厅
                NeedActivity.start(getActivity());
                break;
            case "7-3": //知产交易
                ActivityJump.jumpToActivity(getActivity(), MakeOverActivity.class);
                break;
            case "7-4": //专业团队
                ActivityJump.jumpToActivity(getActivity(), ProfessionalTeamChangeActivity.class);
                break;
            case "8": //会员经营
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 24));
                break;
            case "8-1": //会员管理
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    VerificationCodeLoginActivity.start(getActivity());
                } else {
                    MemberManageActivity.start(getActivity());
                }
                break;
            case "8-2": //邀请会员
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    VerificationCodeLoginActivity.start(getActivity());
                } else {
                    MemberInviteOrApplyActivity.startInviteOrApply(getActivity(), 0);
                }
                break;
            case "8-3": //申请加盟
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    VerificationCodeLoginActivity.start(getActivity());
                } else {
                    MemberInviteOrApplyActivity.startInviteOrApply(getActivity(), 1);
                }
                break;
            case "8-4": //会员审核
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    VerificationCodeLoginActivity.start(getActivity());
                } else {
                    MemberAuditActivity.start(getActivity());
                }
                break;
            case "9": //企业经营
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 23));
                break;
            case "9-1": //经营大厅
                String longitude = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LONGITUDE_ID, "");
                String latitude = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LATITUDE_ID, "");
                ActivityJump.jumpToActivity(getActivity(), ManageActivity.class, Pair.create("latitude", latitude), Pair.create("longitude", longitude));
                break;
            case "9-2": //专项资质
                SpecialQualificationActivity.startAction(getActivity());
                break;
            case "9-3": //知识产权
                IPActivity.startAction(getActivity());
                break;
            case "9-4": //专项资产
                EpAssestActivity.start(getActivity());
                break;
            case "9-5": //荣誉荣耀
                TradeHonorActivity.start(getActivity());
                break;
            case "9-6": //经营动态
                ActivityJump.jumpToActivity(getActivity(), CompanyTradesActivity.class);
                break;
            case "10": //招商引资
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 27));
                break;
            case "10-1": //投资项目
                ARouter.getInstance().build(PathMerchant.InvestmentProjectActivity).navigation();
                break;
            case "10-2": //投资需求
                ARouter.getInstance().build(PathMerchant.DemandListActivity).navigation();
                break;
        }
        //关闭弹框
        if (quickEntryPopWindow != null) {
            quickEntryPopWindow.dismiss();
        }
    }

    private void changeTabFragmentEvent(String id) {
        if (!TextUtils.isEmpty(id) && id.contains("-")) {
            int newId = Integer.parseInt(id.substring(0, id.indexOf("-")));
            switch (newId) {
                case 1:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 1));
                    break;
                case 2:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 2));
                    break;
                case 3:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 3));
                    break;
                case 4:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 4));
                    break;
                case 5:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 5));
                    break;
                case 6:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 6));
                    break;
                case 7:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 22));
                    break;
                case 8:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 24));
                    break;
                case 9:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 23));
                    break;
                case 10:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 27));
                    break;
            }
        }
    }

    public void showImageButtonData(List<MenuEntity> datas, int position, boolean isMap) {
        this.titleData = datas;
        if (mMaterialData == null) {
            mModel.recomandCate(true);
            return;
        }
        DatalUtils.getInstance().putData(MkvUtils.CacheModular, CacheMarker.CacheGoodsCategoryModel, mMaterialData);
        EventBus.getDefault().post(new UpdateIndexEvent(position, getActivity() instanceof GoodsAggregateActivity));

//        GoodsAggregateActivity.start(getActivity(), titleData, position, "", null, null, isMap);
//        new Handler().postAtTime(startActivity(datas,position,isMap),1000);
//        getActivity().finish();
    }


//    public Runnable startActivity(List<MenuEntity> datas, int position, boolean isMap){
//
//        Runnable runnable = new Runnable() {
//            @Override
//            public void run() {
//                DatalUtils.getInstance().putData(MkvUtils.CacheModular, CacheMarker.CacheGoodsCategoryModel, mMaterialData);
//                GoodsAggregateActivity.start(getActivity(), titleData, position, "", null, null, isMap);
//            }
//        };
//        return  runnable;
//    }

    @SuppressLint({"AutoDispose", "CheckResult"})
    public void showRecommendCate(List<HomeMenuEntity> data, boolean isRefresh) {
    }

}
